#include <bits/stdc++.h>
using namespace std;
const int N = 22;
int n;
string s[N];

bool cmp(string a, string b) {
	return a + b > b + a;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	sort(s, s + n, cmp);
	for (int i = 0; i < n; ++i) {
		cout << s[i];
	}
	return 0;
}